<template>
	<view class="warp">
			<!-- <view class="user">
				<view class="user_item" v-for="(item,index) in deptlist" :key="index">
					<view class="left">
						<view class="icon">
							<uni-icons v-if="index==num" type="circle" size="40rpx"></uni-icons>
							<uni-icons v-else type="checkbox" size="40rpx"></uni-icons>
						</view>
						<view class="deptname">
							{{item.deptName}}
						</view>
					</view>
					<view class="right" @click="chooosein(item)">
						<uni-icons type="right" size="40rpx"></uni-icons>
					</view>
				</view>
			</view> -->
			 <view class="user_list">
			 	<view class="user_item" v-for="(item,index) in userList" :key="index">
			 		<view class="left" @click="choosefn(item,index)">
			 			<view class="icon">
			 				
			 				<uni-icons color="#4ae979" v-if="item.show"  type="checkmarkempty" size="25"></uni-icons>
							<uni-icons v-else type="circle" size="18"></uni-icons>
			 			</view>
			 			<view class="deptname">
			 				{{item.nameRemark}}
			 			</view>
			 		</view>
			 		
			 	</view>
			 </view>
		  <view class="bottom">
		  						<view class="btn" @click="btnok">
		  							完成
		  						</view>
		  					</view>
		  					<view class="" style="padding-bottom: 120%;">
		  						
		  					</view>
		  </view>
	</view>
</template>

<script>
	import {
			mapState,
			mapMutations
		} from 'vuex'
	export default {
		data() {
			return {
				queryform:{
					parentId:0,
					storeId:''
				},
				value:'',
				chooselinst:[],
				deptlist:[
					
				],
				userList:[
					 
				],
				num:0
			};
		},
		onLoad() {
			this.getuserlist()
		},
		computed: {
					...mapState(['hasLogin', 'userInfo', 'userCenterData']),
					},
		methods:{
			
			// 获取员工列表
			getuserlist(){
			this.$request({
				url:'v3/task/front/appUserStore/page',
				method:"GET",
				data:{
					storeId:this.userCenterData.memberId
				}
			}).then(res=>{
				this.userList=res.data.list
				this.userList.forEach(item=>{
					item.show=false
				})
			})
			},
			// 选中
			choosefn(val,idx){
				 
				if(val.show==false){
					val.show=true
					this.$set(this.userList,idx,val)
					
					this.chooselinst.push({userName:val.nameRemark,userId:val.userId})
					
				}else{
					val.show=false
					this.$set(this.userList,idx,val)
					console.log(this.userList);
					this.chooselinst.forEach((item,index)=>{
						if(item.userId==val.userId){
							this.chooselinst.splice(index,1)
						}
					})
					
				}
			    
				
							 },
			// 查询子级
			chooosein(val){
				this.queryform.parentId=val.deptId
				this.getuserlist()
			},
			// changeitem(val){
			// 	this.queryform.parentId=val.deptId
			// 	this.getuserlist()
			// },
			// change(val){
			// 	console.log(val,'外');
			// },
			// checkboxGroupChange(val){
			// 	console.log(val,'大盒子');
			// 	this.chooselinst=val
			// },
			// checkboxChange(val){
			// 	console.log(val,'小');
			// },
			// 选中后返回原页面
			btnok(){
				
				// 1. 获取当前页面栈实例（此时最后一个元素为当前页）
				 let pages = getCurrentPages() 
				 // 2. 上一页面实例
				// 注意是length长度，所以要想得到上一页面的实例需要 -2
				// 若要返回上上页面的实例就 -3，以此类推
				let prevPage = pages[pages.length -2] 
				// 3. 给上一页面实例绑定getValue()方法和参数（注意是$vm）
				 prevPage.$vm.getValueS({type:'marketer',list:this.chooselinst}) 
				// 4. 返回上一页面
				 uni.navigateBack({
					 delta: 1 // 返回的页面数
				 })
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		width: 750rpx;
		margin: 0 auto;
		background: #F5F5F5;
	}
.warp{
	background-color: #f7f7f7;
	color: #282828;
	font-family: PingFang-SC-Regular;
	.user_list,.user{
		.user_item{
			padding: 30rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			background-color: #fff;
			.left{
				display: flex;
			}
		}
		
		
	}
	.user_list{
		margin-top: 20rpx;
	}
	.bottom{
		width: 100%;
		height: 140rpx;
		position: fixed;
		bottom: 0rpx;
		z-index: 999;
		background-color: #fff;
		padding:40rpx 30%;
		 
		.btn{
			width: 300rpx;
			height: 60rpx;
			background-color: #fd4954;
			text-align: center;
			line-height: 60rpx;
			border-radius: 25rpx;
			color: #fff;
		
		}
	}
}
</style>
